package nimble.unionpay.openapi;

import org.apache.commons.lang3.StringUtils;

public enum CardAttribute {

    DEBIT_CARD("01","借记卡"),
    CREDIT_CARD("02","贷记卡"),
    QUASI_CREDIT_CARD("03","准贷记卡"),
    DEBIT_AND_CREDIT_CARD("04","借贷合一卡"),
    PREPAID_CARD("05","预付费卡"),
    SEMI_CLOSED_PREPAID_CARD("06","半开放式预付费卡"),
    SINGLE_PURPOSE_PREPAID_CARD("99","单用途预付费卡"),
    UNKNOWN("00","未知");

    private String code;
    private String desc;

    public String getCode()
    {
        return code;
    }

    public String getDesc()
    {
        return desc;
    }

    CardAttribute(String code,String desc)
    {
        this.code=code;
        this.desc=desc;
    }

    public static CardAttribute parse(String code)
    {
        for(CardAttribute cardAttribute:CardAttribute.values())
        {
            if(StringUtils.equalsAny(code,cardAttribute.name(),cardAttribute.getCode()))
            {
                return cardAttribute;
            }
        }
        return null;
    }
}
